package cn.iocoder.yudao.module.infra.dal.mysql.label;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.infra.controller.admin.label.vo.LabelPageReqVO;
import cn.iocoder.yudao.module.infra.dal.dataobject.label.LabelDO;
import org.apache.ibatis.annotations.Mapper;

/**
 * 分类管理 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface LabelMapper extends BaseMapperX<LabelDO> {

    default PageResult<LabelDO> selectPage(LabelPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<LabelDO>()
                .likeIfPresent(LabelDO::getName, reqVO.getName())
                .eqIfPresent(LabelDO::getLabelType, reqVO.getLabelType())
                .eqIfPresent(LabelDO::getEmployCount, reqVO.getEmployCount())
                .eqIfPresent(LabelDO::getRemark, reqVO.getRemark())
                .eqIfPresent(LabelDO::getSort, reqVO.getSort())
                .eqIfPresent(LabelDO::getStatus, reqVO.getStatus())
                .betweenIfPresent(LabelDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(LabelDO::getId));
    }

    default List<LabelDO> selectTypeList() {
        return selectList(new LambdaQueryWrapperX<LabelDO>()
                .eqIfPresent(LabelDO::getLabelType, 0)
                .eqIfPresent(LabelDO::getStatus, 0)
                .orderByAsc(LabelDO::getSort));
    }
}
